﻿using UnityEngine;
using System.Collections;

public class RetraitChaine3 : MonoBehaviour {
	
	public GameObject chaine;
	public float speed;
	public float positionCouranteX;
	public float positionCouranteY;
	public float positionDebutX;
	public float positionDebutY;
	public float positionMaxX;
	public float positionMaxY;
	public float mouvementChaine;
	public static float positionFin;
	
	void Start () {
		positionDebutY = transform.position.y;
		positionDebutX = transform.position.x;
	}
	
	void FixedUpdate () {
		
		positionCouranteX = transform.position.x;
		positionCouranteY = transform.position.y;
		if (positionCouranteX > positionMaxX && HitOrbe.moving3 && positionCouranteY < positionMaxY) {
			if((positionCouranteX < positionDebutX + mouvementChaine) && (positionCouranteY < positionDebutY + mouvementChaine )){
				transform.position += new Vector3 (speed * Time.deltaTime * -1, speed * Time.deltaTime , 0 );
			}
			else{
				positionDebutX = positionCouranteX; 
				positionDebutY = positionCouranteY;
				HitOrbe.moving3 = false;
				positionFin = positionCouranteY;
			}
		}
	}
	
}
